﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UITestHtmlPage.cs" company="">
// </copyright>
// <summary>
//   The UI test html page.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace UITest.SeleniumTestProject
{
    using OpenQA.Selenium;

    using UITest.Selenium.SeleniumContext;
    using UITest.Selenium.SeleniumControls.HtmlControls;

    /// <summary>
    ///     The UI test html page.
    /// </summary>
    public class UITestHtmlPage
    {
        #region Fields

        /// <summary>
        ///     The html 4 combobox.
        /// </summary>
        public SeleniumComboBox html4Combobox;

        /// <summary>
        ///     The html 5 combo box edit.
        /// </summary>
        public SeleniumEdit html5ComboBoxEdit;

        /// <summary>
        ///     The html 5 combo box list.
        /// </summary>
        public SeleniumList html5ComboBoxList;

        /// <summary>
        ///     The html button.
        /// </summary>
        public SeleniumButton htmlButton;

        /// <summary>
        ///     The html checkbox a.
        /// </summary>
        public SeleniumCheckBox htmlCheckboxA;

        /// <summary>
        ///     The html checkbox b.
        /// </summary>
        public SeleniumCheckBox htmlCheckboxB;

        /// <summary>
        ///     The html edit.
        /// </summary>
        public SeleniumEdit htmlEdit;

        /// <summary>
        ///     The html edit under div.
        /// </summary>
        public SeleniumEditUnderDiv htmlEditUnderDiv;

        /// <summary>
        ///     The html editable div.
        /// </summary>
        public SeleniumEditableDiv htmlEditableDiv;

        /// <summary>
        ///     The html input button.
        /// </summary>
        public SeleniumInputButton htmlInputButton;

        /// <summary>
        ///     The html label.
        /// </summary>
        public SeleniumLabel htmlLabel;

        /// <summary>
        ///     The html listbox.
        /// </summary>
        public SeleniumList htmlListbox;

        /// <summary>
        ///     The html radio button female.
        /// </summary>
        public SeleniumRadioButton htmlRadioButtonFemale;

        /// <summary>
        ///     The html radio button male.
        /// </summary>
        public SeleniumRadioButton htmlRadioButtonMale;

        /// <summary>
        ///     The html table with alert on head table.
        /// </summary>
        public SeleniumTable htmlTableWithAlertOnHeadTable;

        /// <summary>
        ///     The html table with header cells.
        /// </summary>
        public SeleniumTable htmlTableWithHeaderCells;

        /// <summary>
        ///     The table with headers.
        /// </summary>
        public SeleniumTable htmlTableWithHeaders;

        /// <summary>
        ///     The html table with special cell.
        /// </summary>
        public SeleniumTable htmlTableWithSpecialCell;

        /// <summary>
        ///     The html text area.
        /// </summary>
        public SeleniumTextArea htmlTextArea;

        /// <summary>
        ///     The htmlfile input.
        /// </summary>
        public SeleniumFileInput htmlfileInput;

        /// <summary>
        /// The selenium.
        /// </summary>
        protected SeleniumContext Selenium;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="UITestHtmlPage"/> class.
        /// </summary>
        /// <param name="seleniumContext">
        /// The selenium context.
        /// </param>
        public UITestHtmlPage(SeleniumContext seleniumContext)
        {
            this.Selenium = seleniumContext;
            this.InitialConstructor();
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The get alert pop up win text.
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string GetAlertPopUpWinText()
        {
            return this.Selenium.WebDriver.SwitchTo().Alert().Text;
        }

        #endregion

        #region Methods

        private void InitialConstructor()
        {
            this.htmlTableWithHeaders = new SeleniumTable(this.Selenium, By.CssSelector("[id='TableWithHeaders']"));
            this.htmlInputButton = new SeleniumInputButton(this.Selenium, "ClickOnMe");
            this.htmlButton = new SeleniumButton(this.Selenium, "Simple Button");
            this.htmlCheckboxA = new SeleniumCheckBox(this.Selenium, By.Name("A"));
            this.htmlCheckboxB = new SeleniumCheckBox(this.Selenium, By.Name("B"));
            this.html4Combobox = new SeleniumComboBox(this.Selenium, By.Name("html4comboboxlist"));
            this.html5ComboBoxEdit = new SeleniumEdit(this.Selenium, By.CssSelector("[list='html5comboboxlist']"));
            this.html5ComboBoxList = new SeleniumList(this.Selenium, By.Id("html5comboboxlist"));
            this.htmlEdit = new SeleniumEdit(this.Selenium, By.Name("text1_test"));
            this.htmlEditableDiv = new SeleniumEditableDiv(this.Selenium, By.Id("EditDiv"));
            this.htmlEditUnderDiv = new SeleniumEditUnderDiv(this.Selenium, By.Id("parentdiv"));
            this.htmlfileInput = new SeleniumFileInput(this.Selenium, By.Id("fileupload"));
            this.htmlLabel = new SeleniumLabel(this.Selenium, "Male");
            this.htmlListbox = new SeleniumList(this.Selenium, By.Name("listbox"));
            this.htmlRadioButtonMale = new SeleniumRadioButton(this.Selenium, By.CssSelector("[name='sex'][id='male']"));
            this.htmlRadioButtonFemale = new SeleniumRadioButton(
                this.Selenium, 
                By.CssSelector("[name='sex'][id='female']"));
            this.htmlTextArea = new SeleniumTextArea(this.Selenium, By.Id("textArea"));
            this.htmlTableWithAlertOnHeadTable = new SeleniumTable(this.Selenium, By.Id("tableWithAlertOnHeaderClick"));
            this.htmlTableWithHeaderCells = new SeleniumTable(this.Selenium, By.Id("TableWithHeaderCells"));
            this.htmlTableWithSpecialCell = new SeleniumTable(this.Selenium, By.Id("TableWithSpecialCell"));
        }

        #endregion
    }
}